//
//  DDShopViewController.m
//  Dingdong
//
//  Created by 程强 on 16/11/16.
//  Copyright © 2016年 程强. All rights reserved.
//

#import "DDShopViewController.h"
#import "DDShopTableCell.h"
#import "DDShopTitleView.h"
#import "DDNineLatticeView.h"

@interface DDShopViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *shopTable;
@property (strong, nonatomic) DDShopTitleView *shopTitleView;
@property (strong, nonatomic) DDNineLatticeView *nineLatticeView;
@end

@implementation DDShopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self layoutShopView];
}
- (void)layoutShopView
{
    UIView *tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 580)];
    tableHeaderView.backgroundColor = RGBColor(244, 244, 244);
    
    self.shopTitleView = [[DDShopTitleView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    [tableHeaderView addSubview:_shopTitleView];
    [_shopTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(tableHeaderView);
        make.height.equalTo(@180);
    }];
    
    self.nineLatticeView = [[DDNineLatticeView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    [tableHeaderView addSubview:_nineLatticeView];
    [_nineLatticeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(tableHeaderView);
        make.top.equalTo(_shopTitleView.mas_bottom).offset(10);
        make.height.equalTo(@380);
    }];
    
    self.shopTable.tableHeaderView = tableHeaderView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 110.0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *indentifier = @"ShopCell";
    
    DDShopTableCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    
    if (!cell) {
        cell = [[DDShopTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
    }
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
